package com.android.physics;

import java.util.ArrayList;
import java.util.List;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;


public class Actor extends PhysicsObject
{
    private static Paint RED_PAINT;
    static
    {
        Paint paint = new Paint();
        paint.setColor(Color.RED);
        RED_PAINT = paint;
    }
    
    private float mMoveStepX = 0;
    private float mMoveStepY = 0;
    
    public Actor()
    {
    }
    
    public void setMoveStep(float stepX, float stepY)
    {
        mMoveStepX = stepX;
        mMoveStepY = stepY;
    }
    
    public float getMoveStepX()
    {
        return mMoveStepX;
    }
    
    public float getMoveStepY()
    {
        return mMoveStepY;
    }
    
    public void draw(Canvas canvas)
    {
        canvas.drawRect(0, 0, getWidth(), getHeight(), RED_PAINT);
    }
    
    public interface OnActorListener
    {
        void onHit();
    }
    
    private List<OnActorListener> mActorListeners = new ArrayList<OnActorListener>(); 
    
    public void regOnActorListener(OnActorListener listener)
    {
        if (listener == null)
        {
            throw new IllegalArgumentException("Input value is null");
        }
        
        mActorListeners.add(listener);
    }
    
    public void unregOnActorListener(OnActorListener listener)
    {
        mActorListeners.remove(listener);
    }
    
    public void hit()
    {
        for (OnActorListener listener : mActorListeners)
        {
            listener.onHit();
        }
    }
}
